package com.etone.smartAudit.controller;


import com.etone.smartAudit.annotation.LoginAdmin;
import com.etone.smartAudit.domain.Admin;
import com.etone.smartAudit.service.WorkOrderService;
import com.etone.smartAudit.vo.PagerVO;
import com.etone.smartAudit.vo.workOrder.WorkOrderVO;
import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * @author 张任豪
 */
@RestController
@AllArgsConstructor
@Api(tags = "我的工单", value = "WorkOrderMyController")
public class WorkOrderMyController {

    private WorkOrderService workOrderService;

    @ApiOperation(value = "我的工单列表")
    @GetMapping("/workMyOrder/list")
    public PagerVO<WorkOrderVO> list(
            @ApiIgnore @LoginAdmin Admin admin,
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize,
            @ApiParam(value = "项目名称") @RequestParam(required = false) String name,
            @ApiParam(value = "整改编号") @RequestParam(required = false) String rectifyCode,
            @ApiParam(value = "工单状态") @RequestParam(required = false) Integer status,
            @ApiParam(value = "整改是否超期") @RequestParam(required = false) Integer isOverdue,
            @ApiParam(value = "工单接收人") @RequestParam(required = false) String wordOrderName
    ) {
        return workOrderService.listMyWorkOrder(page,pageSize,name,rectifyCode,null,null,status,isOverdue,wordOrderName,null,admin);
    }

    @ApiOperation(value = "导出工单")
    @PostMapping("/workMyOrder/exportOrder")
    public void exportOrder(
            @ApiParam("导出工单集合") @RequestBody List<WorkOrderVO> list,
            HttpServletResponse response
    ) {
        workOrderService.exportOrder(list,response);
    }
}
